﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Apollo
{
    public interface IModule
    {
        void OnInit(Application app);

        /// <summary>
        /// This method is invoked before any action is executed
        /// </summary>
        /// <param name="actionName">The name of the action</param>
        /// <param name="obj">The object that the action targets. 
        /// On the actions that will target a group this will be
        /// a IEnumerable of objects</param>
        /// <returns></returns>
        ActionSubscription PrepareAction(string actionName, object obj);

        /// <summary>
        /// When implementing this action you must return an Entity and an EntityEdit.
        /// By using this you're responsable for getting the ID from Form.Request
        /// </summary>
        /// <returns></returns>
        EditActionSubscription PrepareEditAction();

        bool IsAllowed(string actionName, Entity entity, object obj);

        ActionContext Save(object obj);

        ActionContext Delete(object obj);

        ActionContext DoAction(string actionName, object obj);
    }
}
